package com.znpc.valmap;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

/**
 * @Date 2021-09-05 17:52
 * @Author YangFan
 * @Description 文本数值化对应
 */
public class ValMap {

    public static String[] COLORS = new String[]{"PC透明色", "本色", "白色", "金属色", "浅灰色", "浅绿色", "浅蓝色", "黄色", "黑色"};

    public static Map<String, Integer> COLOR_DEPTH = new HashMap<String, Integer>() {{
        put("PC透明色", 1);
        put("本色", 1);
        put("白色", 2);
        put("金属色", 2);
        put("浅灰色", 3);
        put("浅绿色", 3);
        put("浅蓝色", 3);
        put("黄色", 3);
        put("黑色", 5);
    }};

    public static String[] BASE_MATERIALS = new String[]{"POM", "PA6", "PA66", "PC", "PP/PE", "PBT/PET", "PPS", "PPA", "PC/ABS", "PBT/ABS", "PA/PPO", "TPE", "ABS/AS", "PPO", "PMMA", "PC/PBT", "PA/ABS"};
    public static String[] FILL_MATERIALS = new String[]{"无", "G", "GL", "M"};

    // 这一批订单排产的开始生产时间，具体为当天 00:00
    public static LocalDate BEGIN_DATE = LocalDate.of(2021, 8, 1);

    public static int colorVal(String color) {
        for (int i = 0; i < COLORS.length; i++) {
            if (COLORS[i].equals(color)) {
                return i;
            }
        }
        // 其他颜色统一编号为 8
        return 8;
    }

    public static int colorDepthVal(String color) {
        if (!COLOR_DEPTH.containsKey(color)) {
            return 4;
        }
        return COLOR_DEPTH.get(color);
    }

    public static int bmVal(String bm) {
        for (int i = 0; i < BASE_MATERIALS.length; i++) {
            if (BASE_MATERIALS[i].equals(bm)) {
                return i;
            }
        }
        return -1;
    }

    public static int fmVal(String fm) {
        for (int i = 0; i < FILL_MATERIALS.length; i++) {
            if (FILL_MATERIALS[i].equals(fm)) {
                return i;
            }
        }
        return -1;
    }


    public static int dateVal(LocalDate date) {
        return (int) (date.toEpochDay() - BEGIN_DATE.toEpochDay()) * 24;
    }

}
